﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JJY.Log4Net
{
    public class LogHelper
    {
        private const string infomationAppender = "InfomationAppender";
        private const string warningAppender = "WarningAppender";
        private const string errorAppender = "ErrorAppender";

        public static void Infomation(string message)
        {
            Infomation(message, null);
        }

        public static void Infomation(string message, Exception ex)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger(infomationAppender);

            if (ex == null)
            {
                logger.Info(message);
            }
            else
            {
                logger.Info(message, ex);
            }
        }

        public static void Warning(string message)
        {
            Warning(message, null);
        }

        public static void Warning(string message, Exception ex)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger(warningAppender);

            if (ex == null)
            {
                logger.Warn(message);
            }
            else
            {
                logger.Warn(message, ex);
            }
        }

        public static void Error(string message)
        {
            Error(message, null);
        }

        public static void Error(string message, Exception ex)
        {
            log4net.ILog logger = log4net.LogManager.GetLogger(errorAppender);

            if (ex == null)
            {
                logger.Error(message);
            }
            else
            {
                logger.Error(message, ex);
            }
        }

        private static void ConsoleOutput(string message)
        {
            Console.WriteLine(message);
        }
    }
}
